from django.db import models

# Create your models here.
import os
import time

class Carousel(models.Model):
    imgUrl = models.ImageField(upload_to="Carousel", verbose_name='走马灯图片',null=True)

    class Meta:
        verbose_name = "首页走马灯"
        verbose_name_plural = verbose_name

    def __str__(self):
        return "{:05d}".format(self.id)

class ProductCategory(models.Model):
    name = models.CharField(max_length=100)
    class Meta:
        verbose_name = "产品中心类别"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

class Product(models.Model):   
    # 是由Category影响Article
    # category = models.ForeignKey('ProductCategory',on_delete=models.DO_NOTHING)
    category = models.OneToOneField(ProductCategory, unique=True,on_delete=models.DO_NOTHING)
    imgUrl = models.ImageField(upload_to="Product", verbose_name='产品展示图片',null=True)

    class Meta:
        verbose_name = "产品展示图片"
        verbose_name_plural = verbose_name

    def __str__(self):
        return "{:05d}".format(self.id)

class DemoCategory(models.Model):
    name = models.CharField(max_length=100)
    class Meta:
        verbose_name = "应用案例"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

class DemoExample(models.Model):
    category = models.OneToOneField(DemoCategory, unique=True,on_delete=models.DO_NOTHING)
    # category = models.ForeignKey('DemoCategory',on_delete=models.CASCADE)
    synopsis = models.TextField( verbose_name='简介', max_length=100)
    imgUrl = models.ImageField(upload_to="Demo", verbose_name='卡片图片',null=True)
    create_date = models.DateField(verbose_name='时间', auto_now=False)

    class Meta:
        verbose_name = "应用案例卡片图片"
        verbose_name_plural = verbose_name

    def __str__(self):
        return "{:05d}".format(self.id)


class DemoPicture(models.Model):
   
    category = models.ForeignKey('DemoCategory',on_delete=models.DO_NOTHING)
    imgUrl = models.ImageField(upload_to="Demo", verbose_name='应用案例图片',null=True)

    class Meta:
        verbose_name = "应用案例详细图片"
        verbose_name_plural = verbose_name

    def __str__(self):
        return "{:05d}".format(self.id)

class DemoTopPicture(models.Model):
   
    imgUrl = models.ImageField(upload_to="Demo", verbose_name='应用案例顶部图片')

    class Meta:
        verbose_name = "应用案例顶部图片"
        verbose_name_plural = verbose_name

    def __str__(self):
        return "{:05d}".format(self.id)


class AboutUS(models.Model):
   
    synopsis = models.TextField( verbose_name='简介', max_length=1000)
    imgUrl = models.ImageField(upload_to="Demo", verbose_name='关于我们图片')

    class Meta:
        verbose_name = "关于我们"
        verbose_name_plural = verbose_name

    def __str__(self):
        return "{:05d}".format(self.id)


